﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Brainee.Search
{
  /// <summary>
  /// Basic implementation of the ISearchState interface.
  /// </summary>
  class SearchState  : ISearchState
  {
#region Construction

    /// <summary>
    /// Create a new SearchState instance that can be used as the initial state of 
    /// a search algorithm.
    /// </summary>
    /// <param name="state">The state in the problem state space to which this state corresponds</param>
    public SearchState (IState state)
      : this (state, null, null,0, 0)
    { }

    /// <summary>
    /// Create a new SearchState instance.
    /// </summary>
    /// <param name="state">The state in the problem state space to which this state corresponds</param>
    /// <param name="parent">The state that generated this state</param>
    /// <param name="action">The action that was applied to the parent</param>
    /// <param name="pathCost">The total path cost from the initial node</param>
    /// <param name="depth">The number of steps from the initial node</param>
    public SearchState (IState state, ISearchState parent, IAction action, double pathCost, UInt32 depth)
    {
      State = state;
      Parent = parent;
      Action = action;
      PathCost = pathCost;
      Depth = depth;
    }

#endregion
#region ISearchState implementation

    /// <summary>
    /// The state in the problem state space to which this search state corresponds.
    /// </summary>
    public IState State { get; private set; }

    /// <summary>
    /// The state in the search algorithm that generated this state.
    /// </summary>
    public ISearchState Parent { get; private set; }

    /// <summary>
    /// The action that was applied to the parent to generate this state.
    /// </summary>
    public IAction Action { get; private set; }

    /// <summary>
    /// The total cost of the path from the initial state to this node.
    /// </summary>
    public double PathCost { get; private set; }

    /// <summary>
    /// The number of steps along the path from the initial state.
    /// </summary>
    public uint Depth { get; private set; }

#endregion
  }
}
